#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <set>

#define flr(x, l, r) for (int x = l; x <= r; ++x)
#define frl(x, r, l) for (int x = r; x >= l; --x)
#define fmp(x, t) for (int x = h[t]; ~x; x = ne[x])
#define LL long long
#define mt memset
#define my memcpy
#define szf sizeof
#define INF 0x3f3f3f3f
#define in(x) scanf("%d", &x)
#define out(x) printf("%d", x)
#define inll(x) scanf("%lld", &x)
#define outll(x) printf("%lld", x)
#define pn printf("\n")
#define con continue
#define bk break
#define vc vector
#define pb push_back
#define sz size
#define PII pair<int, int>
#define x first
#define y second
#define P_q priority_queue
#define ft front
#define pf push_front
#define popf pop_front
#define it insert
#define ct count

using namespace std;

const int N = 110; 

int n, m;
int d[N][N], g[N][N];
int pos[N][N];
int path[N], cnt;

void get_path(int i, int j) {
    if (!pos[i][j]) return;
    
    int k = pos[i][j];
    get_path(i, k);
    path[cnt ++ ] = k;
    get_path(k, j);
}

int main() {
    in(n), in(m);
    
    mt(g, 0x3f, szf g);
    flr (i, 1, n) g[i][i] = 0;
    
    while (m -- ) {
        int a, b, c;
        in(a), in(b), in(c);
        g[a][b] = g[b][a] = min(g[a][b], c);

    }
    
    my(d, g, szf d);
    int res = INF;
    flr (k, 1, n) {
        flr (i, 1, k - 1)
            flr (j, i + 1, k - 1)
                if ((LL)d[i][j] + g[i][k] + g[k][j] < res) {
                    res = d[i][j] + g[i][k] + g[k][j];
                    cnt = 0;
                    path[cnt ++ ] = k;
                    path[cnt ++ ] = i;
                    get_path(i, j);
                    path[cnt ++ ] = j;
                }
                
        flr (i, 1, n)
            flr (j, 1, n)
                if (d[i][j] > d[i][k] + d[k][j]) {
                    d[i][j] = d[i][k] + d[k][j];
                    pos[i][j] = k;
                }
    }
    
    if (res == INF) printf("No solution.");
    else flr (i, 0, cnt - 1) cout << path[i] << ' '; 
    pn;
    
    return 0;
}